<template>
  <div class="container">
    <header class="header">
      <div class="admin">
        <span>管理员</span>
        <i class="el-icon-user"></i>
      </div>
      <el-button type="primary" class="back-button" @click="goBack"
        >点击返回</el-button
      >
    </header>

    <main class="content">
      <section class="comment-section">
        <h3>留言内容</h3>
        <div class="comment">{{ commentContent }}</div>
      </section>

      <section class="response-section">
        <h3>管理员回复</h3>
        <el-input
          type="textarea"
          :rows="4"
          placeholder="请输入回复内容"
          v-model="responseContent"
        ></el-input>
        <!-- 修改部分：将按钮放置在右侧 -->
        <el-button type="primary" class="submit-button" @click="submitResponse"
          >提交回复</el-button
        >
      </section>
    </main>
  </div>
</template>

<script>
export default {
  data() {
    return {
      commentContent: "", // 留言内容
      responseContent: "", // 管理员回复内容
    };
  },
  created() {
    this.fetchComment();
  },
  methods: {
    fetchComment() {
      // 模拟从后端获取留言内容
      // 实际开发中应替换为API请求
      this.commentContent = "能否添加XXXXX公司的XXXX设备？";
    },
    submitResponse() {
      // 模拟提交回复到后端
      // 实际开发中应替换为API请求
      console.log("提交的回复内容:", this.responseContent);
      // 这里可以添加发送请求的代码，例如使用 axios
    },
    goBack() {
      this.$router.go(-1);
    },
  },
};
</script>

<style scoped>
.container {
  background-color: #feffff;
  height: 100vh;
  box-sizing: border-box;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background-color: #ffffff;
  border-bottom: 1px solid #ddd;
  border-top: 1px solid #ddd;
}

.title {
  font-size: 18px;
  font-weight: bold;
}

.admin {
  display: flex;
  align-items: center;
}

.back-button {
  /* 添加样式以将按钮放在头部右侧 */
  margin-left: auto;
}

.content {
  padding: 24px;
}

.comment-section,
.response-section {
  margin-bottom: 32px;
}

.comment,
.response {
  background-color: #fff;
  border: 1px solid #ddd;
  padding: 12px;
  border-radius: 4px;
  margin-top: 8px;
}

.response-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 32px;
}

/* 修改提交按钮的样式 */
.submit-button {
  margin-top: 16px; /* 新增，为按钮添加一些上边距 */
  align-self: flex-end; /* 新增，将按钮推到右侧 */
}
</style>
